package com.zsy.dao;

import com.zsy.dto.SetmealDto;
import com.zsy.pojo.Setmeal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SetmealDao {

    @Select("select count(*) from Setmeal where category_id=#{categoryId}")
    long findById(long id);


    @Insert("INSERT INTO Setmeal VALUES (null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0);")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void save(SetmealDto setmealDto);



    List<Setmeal> findByName(@Param("name") String name);

    @Select("select *from Setmeal where id=#{id}")
    Setmeal idFind(Long id);

    @Update("UPDATE Setmeal SET category_id=#{categoryId},name=#{name},price=#{price},status=#{status},code=#{code},description=#{description},image=#{image},update_time=#{updateTime},update_user=#{updateUser} WHERE id=#{id};")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void update(SetmealDto setmealDto);

    Long delete(@Param("ids") List<Long> ids);

    long findByIds(@Param("ids") List<Long> ids);


    @Select("select * from Setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> list(@Param("categoryId") Long categoryId, @Param("status") Integer status);

    void updateStatus(@Param("status") Integer status, @Param("ids") List<Long> ids);
}
